/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package filecityclient;

import java.util.List;
import javax.ejb.EJB;
import manager.LogManagerRemote;
import manager.UserManagerRemote;
import remoteEntity.Log;
import static java.lang.System.out;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author viktor
 */
public class Main {
    @EJB
    private static LogManagerRemote logManager;
    @EJB
    private static UserManagerRemote userManager;

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        System.out.println("main now printing all log entries");
        List<Log> logList = logManager.getAllPosts();
       
        for (Log e : logList){
            System.out.println("log entry id="+e.getId()+" message:"+e.getMessage());
        }
        
        out.println("Now attempting to login vho:123");
        attemptLogin("vho","123");
        out.println(userManager.getUser().getFirstname()+" logged in: "+userManager.getLoggedIn());
        
    }
    
    
    private static boolean attemptLogin(String username, String password){
        userManager.setFields(username, password, null, null, null);
        try {
            userManager.login();
        } catch (Exception ex) {
            
        }
        return userManager.getLoggedIn();
    }
}
